﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Export.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.OrderEditViewModels>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content5" ContentPlaceHolderID="HeaderContent" runat="server">
<%
	var fileName = string.Format("Hoadonmuahang_{0:ddMMyyy}.doc", DateTime.Now);
    Response.Buffer = true;
    Response.ContentType = "application/vnd.ms-word";
	Response.AddHeader("content-disposition", "inline; filename = " + fileName);
%>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<style type="text/css">
	h2
	{
		border: none;
		text-align: left;
		font-size: 1.2em;
		padding-left: 0px;
		color: Black;
	}
	table.reporttable
	{
		border: solid 1px #000;
		border-collapse: collapse;
	}
	table.reporttable tr,
	table.reporttable td,
	table.reporttable th
	{
		border: solid 1px #000;
	}

	table.reporttable td
	{
		 padding: 5px;
	}
		
	table.adminlist th a:link, table.adminlist th a:hover, table.adminlist th a:visited
	{
		text-decoration: none;
	}
	.tableheader.adminlist tr, .tableheader.adminlist td
	{
		border:none;
	}
	.tableheader img
	{
		vertical-align:middle;
	}
</style>
<div id="report">
<table width="100%" border=0>
	<tr>
		<td valign="top" style="text-align: center">
			<p><strong>CÔNG TY TNHH MUA QUA</strong><br />
				<strong>Phòng 509 - TT D1 - Văn Chương - Đống Đa - Hà Nội</strong>
			</p>
		</td>
		<td valign="top">
			<p style="text-align: center; margin-top: 0; padding-top: 0; font-size: 11pt;">
				<strong>MUAQUA.VN</strong><br />
            </p>
			<p style="text-align: right; font-style:italic;font-size: 11pt;">Ngày <%= DateTime.Now.Day %> tháng <%= DateTime.Now.Month %> năm <%= DateTime.Now.Year %> </p>
		</td>
	</tr>
</table>
<p style="font-weight:bold; font-size: 14pt;text-align:center;margin: 0; padding: 0;line-height:1em;">HÓA ĐƠN MUA HÀNG TRỰC TUYẾN</p>
    <%if(ViewData["MessageInfo"]==null){ %>
	<fieldset>
		<legend>Chi tiết đơn hàng</legend>
		<table class="reporttable" width="100%">
			<tbody>
			<tr>
				<td class="key">Mã đơn hàng</td>
				<td><%= Html.Encode(Model.Order.ID) %></td>
			</tr>
			<tr>
				<td class="key">Loại đơn hàng</td>
				<td><%= Html.Encode(Model.OrderTypes[Model.Order.TypeID.HasValue?Model.Order.TypeID.Value: SDT.Lib.Common.OrderType.Normal ]) %></td>
			</tr>
			<tr>
				<td class="key">Loại hình thanh toán</td>
				<td><%= Html.Encode(Model.Order.Payment!=null? Model.Order.Payment.Name: string.Empty)%></td>
			</tr>
			<tr>
				<td class="key">Tên khách hàng</td>
				<td><%= Html.Encode(Model.Order.Customer.FullName==null || Model.Order.Customer.FullName==string.Empty? Model.Order.ReFullName: Model.Order.Customer.FullName)%></td>
			</tr>
			<tr>
				<td class="key">Mã bưu điện</td>
				<td><%= Html.Encode(Model.Order.EmsCode) %></td>
			</tr>
			<tr>
				<td class="key">Phiếu giảm giá</td>
				<td><%= Html.Encode(Model.Order.Coupon) %></td>
			</tr>
			<tr>
				<td class="key">Ngày đặt mua</td>
				<td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}",Model.Order.AddDate)) %></td>
			</tr>
			<tr>
				<td class="key">Ngày mong muốn nhận hàng</td>
				<td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}",Model.Order.ReceiveDate)) %></td>
			</tr>
			<tr>
				<td class="key">Ngày giao hàng</td>
				<td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}",Model.Order.DeliveryDate)) %></td>
			</tr>
			<tr>
				<td class="key">Ghi chú</td>
				<td><%= Html.Encode(Model.Order.Note) %></td>
			</tr>					
			</tbody>
		 </table>
	 </fieldset>
	 <table width="100%">
	    <tr>
	        <td width="50%">
	            <fieldset>
		            <legend>Thông tin người mua hàng</legend>
		            <table class="reporttable"  width="100%">
			            <tbody>            			
			            <tr>
				            <td class="key">Họ tên</td>
				            <td><%= Html.Encode(Model.Order.SeFullName == null || Model.Order.SeFullName == string.Empty ? Model.Order.ReFullName : Model.Order.SeFullName)%></td>
			            </tr>
			            <tr>
				            <td class="key">Điện thoại</td>
				            <td><%= Html.Encode(Model.Order.SePhone == null || Model.Order.SePhone == string.Empty ? Model.Order.RePhone : Model.Order.SePhone)%></td>
			            </tr>
			            <tr>
				            <td class="key">Email khách hàng</td>
				            <td><%= Html.Encode(Model.Order.SeEmail == null || Model.Order.SeEmail == string.Empty ? Model.Order.ReEmail : Model.Order.SeEmail)%></td>
			            </tr>
			            <tr>
				            <td class="key">Địa chỉ khách hàng</td>
				            <td><%= Html.Encode(Model.Order.SeAddress == null || Model.Order.SeAddress == string.Empty ? Model.Order.ReAddress : Model.Order.SeAddress)%></td>
			            </tr>			
			            </tbody>
		             </table>
	             </fieldset>
	        </td>
	        <td width="50%">
	            <fieldset>
		            <legend>Thông tin người nhận hàng</legend>
		            <table class="reporttable"  width="100%">
			            <tbody>
            			
			            <tr>
				            <td class="key">Tên người nhận</td>
				            <td><%= Html.Encode(Model.Order.ReFullName) %></td>
			            </tr>
			            <tr>
				            <td class="key">Điện thoại</td>
				            <td><%= Html.Encode(Model.Order.RePhone) %></td>
			            </tr>
			            <tr>
				            <td class="key">Email khách hàng</td>
				            <td><%= Html.Encode(Model.Order.ReEmail) %></td>
			            </tr>
			            <tr>
				            <td class="key">Địa chỉ khách hàng</td>
				            <td><%= Html.Encode(Model.Order.ReAddress) %></td>
			            </tr>			
			            </tbody>
		             </table>
	             </fieldset>	        
	        </td>
	    </tr>
	 </table>
	 <fieldset>
        <legend>Danh sách sản phẩm đặt mua</legend>
        <table class="reporttable"  width="100%">
            <tr>
                <th width="30">STT</th>
                <th>Tên sản phẩm</th>
                <th width="150">Số lượng</th>
                <th width="150">Đơn giá</th>
                <th width="150">Thành tiền</th>
            </tr>
            <%var index = 1;
            foreach (var item in Model.Order.OrderDetails) { %>
              <tr>
                  <td><%=index++ %></td>
                  <td><%=item.Product.Name %></td>
                  <td><%=item.Quantity %></td>
                  <td style="text-align:right;"><%=string.Format("{0:0,0.0}",item.Price) %> </td> 
                  <td style="text-align:right;"><%=string.Format("{0:0,0.0}",item.Price*item.Quantity) %> </td>                  
              </tr>
             <% } %>
             <tr>
                <td colspan="2" align="right">Tổng</td>
                <td><strong><%=Model.Order.OrderDetails.Sum(e=>e.Quantity)%></strong></td>
                <td></td>
                <td style="text-align:right;" >
					<%var total = Model.Order.OrderDetails.Sum(e => e.Price * e.Quantity); %>
                   <strong><%=string.Format("{0:0,0.0}",total) %> </strong>                      
				</td>
             </tr>
             <tr>               
                <td colspan="4" style="text-align:right;"><strong>Phí chuyển hàng</strong> </td>
                <td style="text-align:right;" >
                   <strong><%=Model.Order.ShippingValue.HasValue? string.Format("{0:0,0.0}",Model.Order.ShippingValue):"0" %> </strong>                      
				</td>
             </tr>
             <tr>               
                <td colspan="4" style="text-align:right;"><strong>Tổng giá trị đơn hàng</strong> </td>
                <td style="text-align:right;" >
					<%var totalAll =Model.Order.TotalValue.HasValue? Model.Order.TotalValue.Value: Model.Order.OrderDetails.Sum(e => e.Price * e.Quantity); %>
                   <strong><%=string.Format("{0:0,0.0}", totalAll)%> </strong>                      
				</td>
             </tr>
             <tr>
                <td colspan="5" align="right"><strong>Số tiền bằng chữ: <i><%=SDT.Lib.Common.Utils.TranlateMoney(totalAll)%></i></strong></td>
             </tr>
        </table>
     </fieldset>
<% } %>
</div>
</asp:Content>